#include <iostream>
#include <string>
using namespace std;

int getLongestPalindrome(string A) {
    if(A.length() == 0) return 0;
    if(A.length() == 1) return 1;
    if(A.length() == 2){
        if(A[0] == A[1]) return 2;
        return 1;
    }

    int maxlen = -1;
    int left;
    int right;

    // odd
    for(int i=0;i<A.length();i++){
        left = i-1;
        right = i+1;
        while(left >= 0 && right < A.size()){
            if(A[left] == A[right]){
                left--;
                right++;
            }else break;
        }
        maxlen = max(maxlen, right-left-1);
    }

    // even
    for(int i=0;i<A.length();i++){
        left = i;
        right = i+1;
        while(left>= 0 && right < A.length()){
            if(A[left] == A[right]){
                left--;
                right++;
            }else break;
        }
        maxlen = max(maxlen, right-left-1);
    }
    return maxlen;
}